<template>
	<view style="height: 100vh; background-color: #EEEEEE;">
		<view
			style="background-image: url(../../static/img/banner-xiaofang.png); background-size: cover; height: 210px;">
			<u-navbar title-color="#FFFFFF" back-icon-color="#FFFFFF" height="48" :background="{opacity: 1}"
				:border-bottom="false" :is-fixed="true" :title="'消防管理中心'"></u-navbar>
		</view>
		<view class="menu_card"
			style="width: 96%; margin-left: 2%;border-radius: 8px; padding: 8px; background-color: #FFFFFF;margin-bottom: 34px;margin-top: -24px;"
			v-for="(model, ind) in menuList" :key="ind" :index="ind">
			<view>
				<view
					style="margin-top: 5px; width: 3px; float: left; margin-right: 10px; height: 14px; margin-top: 2.5px; background-color: #2E84FF;">
				</view><text>{{model.name}}</text>
			</view>
			<u-grid col="3" :border="false" style="margin-top: 10px; margin-bottom: 10px;">
				<u-grid-item v-for="(item,index) in model.child" :name="item.title" :key="index" :index="index"
					@click="itemClick(item)" style="margin-top: 10px;">
					<u-badge v-if="item.badge!=0" :count="item.badge" :offset="[20,30]"></u-badge>
					<image style="height: 58px; width: 58px;" :src="item.icon">
						<view class="grid-text" style="margin-top: 10px;">{{item.title}}</view>
				</u-grid-item>
			</u-grid>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				menuList: [{
						name: "警情管理",
						child: [{
								badge: 0,
								icon: '../../static/img/fire_info_yj.png',
								color: "#5098FF",
								title: "火情消息",
								path: '/pages/index/fireInfo/list',
							},
							{
								badge: 0,
								icon: '../../static/img/xiaofang_yujingxinxi.png',
								color: "#5098FF",
								title: "预警信息",
								path: '/pages/index/alarm/list',
							}
						]
					},
					{
						name: "主体管理",
						child: [{
								badge: 0,
								icon: '../../static/img/xiaofang_jianzhuxinxi.png',
								color: "#5098FF",
								title: "建筑信息",
								path: '/pages/index/build/list',
							},
							{
								badge: 0,
								icon: '../../static/img/yihuanqiye.png',
								color: "#5098FF",
								title: "隐患企业",
								path: '/pages/index/enterprise/list',
							},
							{
								badge: 0,
								icon: '../../static/img/yichangqiye.png',
								color: "#5098FF",
								title: "异常企业",
								path: '/pages/index/enterprise/abnormalEnterpriseList',
							}
						]
					},
					{
						name: "日常工作",
						child: [
							{
								badge: 0,
								icon: '../../static/img/xiaofang_renwulingqu.png',
								color: "#5098FF",
								title: "监督检查",
								path: '/pages/index/inspect/list',
							},
							{
								badge: 0,
								icon: '../../static/img/xiaofang_xiaofangyinhuan.png',
								color: "#5098FF",
								title: "消防隐患",
								path: '/pages/index/firedanger/index',
							},
							{
								badge: 0,
								icon: '../../static/img/weibaogongdan.png',
								color: "#5098FF",
								title: "维保工单",
								code: "wbgd",
								path: '/pages/index/workorder/maintenance/list',
							}
						]
					}
				]
			}
		},
		computed: {
			hiddenButton() {
				let roleCode = this.$store.getters.roleCode;
				return roleCode == "XFZD-ADMIN" || roleCode == "XT-ADMIN" || roleCode == "ZD-ADMIN" || roleCode ==
					"DD-ADMIN" || roleCode == "JW-ADMIN" || roleCode == "XZ-ADMIN"
			}
		},
		onShow() {
			this.menuList = [{
					name: "警情管理",
					child: [{
							badge: 0,
							icon: '../../static/img/fire_info_yj.png',
							color: "#5098FF",
							title: "火情消息",
							path: '/pages/index/fireInfo/list',
						},
						{
							badge: 0,
							icon: '../../static/img/xiaofang_yujingxinxi.png',
							color: "#5098FF",
							title: "预警信息",
							path: '/pages/index/alarm/list',
						}
					]
				},
				{
					name: "主体管理",
					child: [{
							badge: 0,
							icon: '../../static/img/xiaofang_jianzhuxinxi.png',
							color: "#5098FF",
							title: "建筑信息",
							path: '/pages/index/build/list',
						},
						{
							badge: 0,
							icon: '../../static/img/yihuanqiye.png',
							color: "#5098FF",
							title: "隐患企业",
							path: '/pages/index/enterprise/list',
						},
						{
							badge: 0,
							icon: '../../static/img/yichangqiye.png',
							color: "#5098FF",
							title: "异常企业",
							path: '/pages/index/enterprise/abnormalEnterpriseList',
						}
					]
				},
				{
					name: "日常工作",
					child: [
						{
							badge: 0,
							icon: '../../static/img/xiaofang_renwulingqu.png',
							color: "#5098FF",
							title: "监督检查",
							path: '/pages/index/inspect/list',
						},
						{
							badge: 0,
							icon: '../../static/img/xiaofang_xiaofangyinhuan.png',
							color: "#5098FF",
							title: "消防隐患",
							path: '/pages/index/firedanger/index',
						},
						{
							badge: 0,
							icon: '../../static/img/weibaogongdan.png',
							color: "#5098FF",
							title: "维保工单",
							code: "wbgd",
							path: '/pages/index/workorder/maintenance/list',
						}
					]
				}
			]
			if (this.hiddenButton) {
				this.addMenu()
			}
		},
		methods: {
			itemClick(item) {
				if (item.title == "发起演练") {
					//判断用户的角色数据
					if (this.$store.getters.roleCode == "XZ-ADMIN") {
						uni.navigateTo({
							url: item.path
						})
					} else {
						uni.navigateTo({
							url: "/pages/index/choice/choice"
						})
					}
				} else {
					uni.navigateTo({
						url: item.path
					})
				}
			},
			addMenu() {
				this.menuList[0].child.push({
					badge: 0,
					icon: '../../static/img/xiaofang_yanlian.png',
					color: "#5098FF",
					title: "发起演练",
					path: '/pages/index/drill/drillNotice'
				})
			},
			OpenTel() {
				window.native.getLocation(res => {
					console.log(res)
				})
			},
			test() {
				window.native.h5Camera(res => {

				})
				window.native.getUri(res => {
					console.log(res)
				})
			}
		}
	}
</script>

<style lang="scss">

</style>
